﻿using myDocumentClustering.DocumentTermMatrix;
using myDocumentClustering.SAM;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace myDocumentClustering
{
    class Program
    {
        static void Main(string[] args)
        {
            DTMCreator dtm = new DTMCreator();
            //dtm.LoadFilesRecursively(@"E:\myWork\Pasa\Benchmak\Files\SOFiles.Title.Body.128");
            dtm.LoadFilesRecursively(@"E:\myWork\Pasa\Benchmak\Files\PATENTCORPUS128");
            //dtm.LoadFilesRecursively(@"E:\myWork\Pasa\PATENTCORPUS-2");
            dtm.GenerateDTM(false, true, false, false);

            Int32 expectedClusterNumber = 8;
            SAMWorker worker = new SAMWorker(dtm.docs, dtm.dtMatrix, expectedClusterNumber);

            worker.InitializeRandomClustering(expectedClusterNumber);
            Console.WriteLine("Initial random result:");
            worker.OutputResult();
            Console.ReadLine();

            Int32 maxIteration = 4;
            for (Int32 i = 0; i < maxIteration; i++)
            {
                Console.WriteLine("---------------Iteration:{0}---------------", i);
                worker.SplitGen1ToGen2(true); // this step is quick
                worker.MergeGen2toGen1(); // this step is SLOW! We should use result table to optimize here first!
                Console.WriteLine("\rAfter Iteratio:{0}", i);
                worker.OutputResult();
                //Console.ReadLine();
            }
            Console.WriteLine();
            Console.WriteLine();
        }
    }
}
